<!--
 * @Date: 2024-08-21 14:21:19
 * @Author: huading.zhou
 * @LastEditors: huading.zhou
 * @LastEditTime: 2025-01-07 10:10:07
 * @Description:
-->
<script lang="ts" setup>
import { $t } from "@/locales";
defineOptions({ name: 'EmptyBase' });

interface Props {
  /** description text */
  description?: string;
  /** 默认default  store门店 message消息 search搜索 data数据 location定位 moto车辆 track轨迹 energy能源 notes问卷备注*/
  type?: 'default' | 'store' | 'message' | 'search' | 'data' | 'location' | 'moto' | 'track' | 'energy' | 'notes' | null;
  /** in the middle of the page or not */
  middle?: boolean;
}

const props = defineProps<Props>();
</script>

<template>
  <div :class="['empty-page', { 'marginT': middle }]">
    <div v-if="props.type" :class="['empty-img', 'empty-' + props.type]"></div>
    <div v-else class="empty-default"></div>
    <p class="text-des" v-html="props.description || $t('common.nodata')"></p>
    <slot></slot>
  </div>
</template>

<style scoped lang="scss">
.empty-page {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  &.marginT {
    margin-top: 200px;
    height: auto;
  }
  .empty-default {
    width: 129px;
    height: 110px;
    background: url($serverImg + 'logo-grey2x.png') no-repeat center;
    background-size: cover;
  }
  .empty-img {
    width: 240px;
    height: 150px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
  }
  .empty-store {
    background-image: url($serverImg + 'empty/empty-store2x.png');
  }
  .empty-message {
    background-image: url($serverImg + 'empty/empty-message2x.png');
  }
  .empty-search {
    background-image: url($serverImg + 'empty/empty-search2x.png');
  }
  .empty-data {
    background-image: url($serverImg + 'empty/empty-data2x.png');
  }
  .empty-location {
    background-image: url($serverImg + 'empty/empty-location2x.png');
  }
  .empty-moto {
    background-image: url($serverImg + 'empty/empty-moto2x.png');
  }
  .empty-track {
    background-image: url($serverImg + 'empty/empty-track2x.png');
  }
  .empty-energy {
    background-image: url($serverImg + 'empty/empty-energy2x.png');
  }
  .empty-notes {
    background-image: url($serverImg + 'empty/empty-notes2x.png');
  }

  .text-des {
    max-width: 80%;
    text-align: center;
    font-size: 14px;
    line-height: 1.5;
    color: #bbb;
    margin-top: 24px;
    margin-bottom: 12px;
  }
}
</style>
